package it.gestoreContratti.gui.frames;

import it.gestoreContratti.database.DatabaseController;
import it.gestoreContratti.entity.Contratto;
import it.gestoreContratti.gui.panels.ContrattiScadenzaPanel;
import it.gestoreContratti.gui.panels.ProrogaContrattoPanel;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class ProrogaContrattoFrame extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3214484205315814088L;
	private JPanel contentPane;
	private ContrattiScadenzaPanel pannello;

	

	/**
	 * Create the frame.
	 */
	public ProrogaContrattoFrame(ContrattiScadenzaPanel panel) {
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				pannello.refresh();
			}
		});
		this.pannello = panel;
		setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		setBounds(100, 100, 370, 207);
		setTitle("Proroga Contratto Numero: "+pannello.getSelectedContratto().getNumero().toString());
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		GridBagLayout gbl_contentPane = new GridBagLayout();
		gbl_contentPane.columnWidths = new int[]{0, 0};
		gbl_contentPane.rowHeights = new int[]{0, 0};
		gbl_contentPane.columnWeights = new double[]{1.0, Double.MIN_VALUE};
		gbl_contentPane.rowWeights = new double[]{1.0, Double.MIN_VALUE};
		contentPane.setLayout(gbl_contentPane);
		
		ProrogaContrattoPanel prorogaContrattoPanel = new ProrogaContrattoPanel(pannello.getDatabaseController(), pannello.getSelectedContratto());
		GridBagConstraints gbc_prorogaContrattoPanel = new GridBagConstraints();
		gbc_prorogaContrattoPanel.fill = GridBagConstraints.BOTH;
		gbc_prorogaContrattoPanel.gridx = 0;
		gbc_prorogaContrattoPanel.gridy = 0;
		contentPane.add(prorogaContrattoPanel, gbc_prorogaContrattoPanel);
	}

}
